package o;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources.NotFoundException;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Looper;
import android.os.Message;
import android.widget.Toast;

public class evk {
    private static evk ˋ;
    private Toast ˊ;
    private Handler ˎ = new Handler(Looper.getMainLooper());
    private Runnable ˏ = new Runnable(this) {
        final /* synthetic */ evk ˋ;

        {
            this.ˋ = r1;
        }

        public void run() {
            if (this.ˋ.ˊ != null) {
                evk.ˏ();
            }
        }
    };
    private int ॱ = 2000;

    private static synchronized evk ˊ() {
        evk o_evk;
        synchronized (evk.class) {
            if (ˋ == null) {
                ˋ = new evk();
            }
            o_evk = ˋ;
        }
        return o_evk;
    }

    public static void ˏ() {
        if (ˊ().ˊ != null) {
            ˊ().ˊ.cancel();
            ˊ().ˎ.removeCallbacks(ˊ().ˏ);
            ˊ().ˊ = null;
        }
    }

    public static evk ˋ(Context context, CharSequence charSequence, int i) {
        evk ˊ = ˊ();
        ˊ.ˎ(charSequence, i);
        return ˊ;
    }

    public static void ˏ(Context context, int i) {
        ॱ(context.getText(i), 0).ˋ();
    }

    public static void ॱ(CharSequence charSequence) {
        ॱ(charSequence, 0).ˋ();
    }

    public static evk ॱ(CharSequence charSequence, int i) {
        evk ˊ = ˊ();
        ˊ.ˎ(charSequence, i);
        return ˊ;
    }

    public static evk ˏ(Context context, int i, int i2) throws NotFoundException {
        return ˋ(context, context.getResources().getString(i), i2);
    }

    public static void ˏ(final String str) {
        new Handler(Looper.getMainLooper(), new Callback() {
            public boolean handleMessage(Message message) {
                evk.ˋ(ContentManager.getInstant().getContext(), str, 0).ˋ();
                return true;
            }
        }).sendEmptyMessage(0);
    }

    public void ˋ() {
        this.ˎ.post(new Runnable(this) {
            final /* synthetic */ evk ˊ;

            {
                this.ˊ = r1;
            }

            public void run() {
                if (this.ˊ.ˊ != null) {
                    this.ˊ.ˊ.show();
                } else {
                    Logger.e("Toast", "mToast is null");
                }
            }
        });
        this.ˎ.removeCallbacks(this.ˏ);
        this.ˎ.postDelayed(this.ˏ, (long) this.ॱ);
    }

    @SuppressLint({"ShowToast"})
    private void ˎ(final CharSequence charSequence, final int i) {
        this.ˎ.post(new Runnable(this) {
            final /* synthetic */ evk ॱ;

            public void run() {
                if (azc.ˎ().ॱ() >= 17) {
                    if (this.ॱ.ˊ != null) {
                        Logger.ˎ("Toast", "mToast is not null, cancel the last");
                        this.ॱ.ˊ.cancel();
                    }
                    this.ॱ.ˊ = Toast.makeText(azc.ॱ(ContentManager.getInstant().getContext()), charSequence, i);
                } else if (this.ॱ.ˊ != null) {
                    Logger.ˎ("Toast", "mToast is not null, reset the last");
                    this.ॱ.ˊ.setText(charSequence);
                } else {
                    this.ॱ.ˊ = Toast.makeText(azc.ॱ(ContentManager.getInstant().getContext()), charSequence, i);
                }
            }
        });
        if (1 == i) {
            this.ॱ = 3500;
        }
    }
}
